package Cantella::DJabberd::Web::UI::ViewPort::Collection::Grid::Member;

use Reaction::Class;
use aliased 'Cantella::DJabberd::Web::UI::ViewPort::Field::JID';
use aliased 'Cantella::DJabberd::Web::UI::ViewPort::Field::String::Fragment';
use aliased 'Cantella::DJabberd::Web::UI::ViewPort::Field::RelatedObject::Linked';

extends 'Reaction::UI::ViewPort::Collection::Grid::Member';

sub _build_fields_for_type_Cantella_DJabberd_Types_JID  {
  my ($self, $attr, $args) = @_;  
  $self->_build_simple_field(
                             attribute => $attr, 
                             class => JID, 
                             layout => 'value/string', 
                             %$args,
                            );
}

around _build_fields_for_type_Str => sub {
  $_[0]->(@_[1,2], { class => Fragment, %{ $_[3] || {}} });
};

around _build_fields_for_type_Reaction_InterfaceModel_Object => sub {
  my $args = { 
              class => Linked, 
              layout => 'value/related_object/linked',
              %{ $_[3] || {} } 
             };
  return $_[0]->(@_[1,2], $args);
};

__PACKAGE__->meta->make_immutable;

1;
